package com.xmsit.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.xmsit.pojo.CarInfo;
import com.xmsit.service.CarInfoService;
import com.xmsit.mapper.CarInfoMapper;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* @author 徐
* @description 针对表【car_info(汽车数据)】的数据库操作Service实现
* @createDate 2025-04-18 22:09:18
*/
@Service
public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo>
    implements CarInfoService{



    @Override
    public List<CarInfo> getCarList(CarInfo carInfo) {
        PageHelper.startPage(carInfo.getPage(),carInfo.getSize());
        LambdaQueryWrapper<CarInfo> queryWrapper = new LambdaQueryWrapper<>();
        if(carInfo.getVin() != null){
            queryWrapper.eq(CarInfo::getVin,carInfo.getVin());
        }
        if(carInfo.getType() != null){
            queryWrapper.eq(CarInfo::getType,carInfo.getType());
        }
        if(carInfo.getPowerType() != null){
            queryWrapper.eq(CarInfo::getPowerType,carInfo.getPowerType());
        }
        List<CarInfo> carInfos = baseMapper.selectList(queryWrapper);
        return carInfos;
    }
}




